from piercing.pierc_common import PiercParams
import math


# 穿心解卡通过性计算
# 不同外径d工具的最大刚性长度
def get_maximum_rigid_length(params: PiercParams) -> float:
    factor_a: float = params.curvature_radius + params.casing_inner_diameter / 1000 / 2
    factor_b: float = (params.curvature_radius - params.casing_inner_diameter / 1000 / 2 +
                       params.tool_outer_diameter / 1000)
    L_max: float = 2 * math.sqrt(math.pow(factor_a, 2) - math.pow(factor_b, 2))

    return L_max


if __name__ == '__main__':
    params = PiercParams()
    params.curvature_radius = 30
    params.casing_inner_diameter = 120
    params.tool_outer_diameter = 104.9
    L_max = get_maximum_rigid_length(params)
    print(L_max)
